package com.mxpio.erp.common.technology.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.mxpio.erp.common.jpa.policy.ResCodeGeneratorPolicy;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.system.entity.TreeAble;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_INVENTORY_ITEM_GROUP")
@Schema(description="物料组")
public class ItemGroup extends BaseEntity implements TreeAble<ItemGroup> {
	
	private static final long serialVersionUID = 1L;

	@Id
	@Generator(policy = ResCodeGeneratorPolicy.class)
	@Schema(description = "组代码")
	@Column(name = "GROUP_CODE_", updatable = false)
	private String groupCode;

	@Schema(description = "组名称")
	@Column(name = "GROUP_NAME_", length=20, nullable=false)
	private String groupName;
	
	@Schema(description = "组描述")
	@Column(name = "GROUP_DESC_")
	private String groupDesc;
	
	@Schema(description = "父物料组代码")
	@Column(name = "FA_GROUP_CODE_")
	private String faGroupCode;
	
	@Transient
	private List<ItemGroup> children;

	@Override
	public List<ItemGroup> getTreeChildren() {
		return children;
	}

	@Override
	public String getCurrentNodeKey() {
		return groupCode;
	}

	@Override
	public String getParentNodeKey() {
		return faGroupCode;
	}

	@Override
	public void setTreeChildren(List<ItemGroup> children) {
		this.children = children;
	}

}
